package eu.jpereira.trainings.designpatterns.structural.decorator.channel.decorator;

import eu.jpereira.trainings.designpatterns.structural.decorator.channel.SocialChannel;

public class WordCensor extends SocialChannelDecorator{

	String censoredWord;
	String myMessage;
	
	public WordCensor(String censoredWord){
		this.censoredWord = censoredWord;
	}
	
	
	@Override
	public void deliverMessage(String message) {
	
		myMessage = message.replace(censoredWord,"xxx");
		
		delegate.deliverMessage(myMessage);
	}
	
	public WordCensor(String censoredWord, SocialChannel decoratedChannel) {
		this.censoredWord = censoredWord;
		this.delegate = decoratedChannel;
	}

}
